/*
 *  Copyright (C) 2009  Peter Kist & Jan Ripke
 *
 *  This program is free software: you can redistribute it and/or modify
 *  it under the terms of the GNU General Public License as published by
 *  the Free Software Foundation, either version 3 of the License, or
 *  (at your option) any later version.
 *
 *  This program is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU General Public License for more details.
 *
 *  You should have received a copy of the GNU General Public License
 *  along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */

#ifndef __gfx_ogre3d_menu_manager_h
#define __gfx_ogre3d_menu_manager_h 1

#include <boost/shared_ptr.hpp>
#include <boost/weak_ptr.hpp>

//#include <OIS/OISMouse.h>


#include <Core/Interface/Gfx.h>
#include <Modules/Gfx/Ogre/Types.h>
#include <Core/Interface/Input.h>


namespace CEGUI {
    enum MouseButton;
	class OgreRenderer;
}


namespace galaxy {

    namespace input {
        class KeyEvent;
        class MouseEvent;
    }

    namespace gfx {
        namespace ogre3d {
            namespace gui {

            class Injector;

            /** Manages the menu's that are shown on screen. Only one menu can be visible at the time.
            */
            class MenuManager
            {
                // CEGUI setup
                CEGUI::OgreRenderer * m_CEGUIRenderer;

                // the gfx manager
                Manager       * m_Manager;            /**< the associated gfx manager */
                bool            m_Initialized;        /**< init flag for the menu manager */
                MenuPtr         m_CurrentMenu;        /**< the current menu that is on screen */
                gui::Injector * m_GuiInjector;  /**< handles key and mouse event injection into CEGUI */

                MenuManager (void) { }; /**< intentionally private */

            public:
                MenuManager(Manager& manager);
                virtual ~MenuManager (void);

                /** Initialize the CEGUI system. 
                * Creates a CEGUI::System object and a CEGUI::Renderer object.
                * @return returns true upon success and false upon error
                */
                bool initialize ();

                bool changeMenu (gfx::Menu::Name& menuName);
                bool hideMenu ();

                bool handleMouseEvent (input::MouseEvent& event);
                bool handleKeyEvent (input::KeyEvent& event);

                Manager * getManager () { return m_Manager; };
            };

            } // namespace gui
        } // namespace ogre3d
    } // namespace gfx
} // namespace galaxy

#endif // __gfx_ogre3d_menu_manager_h
